<?php get_backend_header(array(
        'ckeditor/ckeditor.js',
	'jquery/validate/jquery.validate.js',
	'jquery/validate/additional-methods.js',
	'message.js',
), array(
	'jquery/ui.jqgrid.css'
)); ?>

<h2 class="title"> Create Message</h2>

<form id="message_form" name="message_form" class="form" method="POST" enctype="multipart/form-data" action="<?php echo site_url('message/submit'); ?>">

            <div class="unit">

                <div class="line">
                        <label for="" class="">Recipient:</label>
                        <div class="field" style="height:auto">
                            <select id="recipient" name="recipient" >
                                <option value="">-Select Recipient-</option>
                                <?php  echo html_options($users, 'user_id','', 'name', $user_id, false); ?>
                            </select>

                        </div>
                </div>
                
                <div class="line">
                        <label for="" class="">Subject:</label>
                        <div class="field" style="height:auto; width:auto;">
                            <input type="text" name="subject" id="subject" value="<?php echo $subject;?>"/>
                        </div>
                </div>


                <div class="line">
                        <label for="" class="">Message:</label>
                        <div class="field" style="height:auto; width:auto;">
                            <textarea id="message" name="message"><?php echo $message;?></textarea>
                        </div>
                </div>
   

            </div>

        <div class ="clear"></div>
        
    	<div class="buttons">
		<button  id="send" name="send">Send</button>
		<button  id="save" name="save">Save as Draft</button>
		<a href="<?php echo site_url('message'); ?>" id="cancel" name="cancel">Cancel</a>
	</div>

        <div class ="clear"></div>


</form>


<script type="text/javascript">
        messageRules();


	$('#cancel').button({
		icons: {primary: 'ui-icon-arrowreturn-1-w'}
	});	
	
	$('#send').button({
		icons: {primary: 'ui-icon-disk'}
	}).click(function(e) {
		$(this).removeClass('ui-state-focus');
		$('#message_form').submit();
		e.preventDefault();
	});	
        
	$('#save').button({
		icons: {primary: 'ui-icon-disk'}
	}).click(function(e) {
		$(this).removeClass('ui-state-focus');
		saveDraft();
		e.preventDefault();
	});	

</script>

<?php get_backend_footer(); ?>
